/**
 * API接口统一入口文件
 * 按功能模块分类导出所有API接口
 * 
 * 支持三种使用方式：
 * 1. 按需导入：import { authApi } from '@/api'
 * 2. 统一调用：import api from '@/api'; api.auth.login()
 * 3. 直接导入：import authApi from '@/api/auth.js'
 * 
 * ⚠️ 注意：所有使用 authApi 等变量的地方必须先导入，否则会报 `ReferenceError`
 */

// 引入HTTP工具（使用相对路径）
import http from '../utils/request.js'

// 模块化导入API
import authApi from './auth.js'
import userApi from './user.js'
import productApi from './product.js'
import cartApi from './cart.js'
import orderApi from './order.js'
import paymentApi from './payment.js'
import messageApi from './message.js'
import friendApi from './friend.js'
import groupApi from './group.js'
import portApi from './port.js'
import shipApi from './ship.js'

// 按名导出，支持按需引入（tree-shaking友好）
export {
  authApi,
  userApi,
  productApi,
  cartApi,
  orderApi,
  paymentApi,
  messageApi,
  friendApi,
  groupApi,
  portApi,
  shipApi
}

// 默认导出统一对象，便于全局调用
const api = {
  auth: authApi,
  user: userApi,
  product: productApi,
  cart: cartApi,
  order: orderApi,
  payment: paymentApi,
  message: messageApi,
  friend: friendApi,
  group: groupApi,
  port: portApi,
  ship: shipApi
}

export default api